class Solution {
public:
    vector<string> split(const string &s, char delit)
    {
        vector<string> res;
        stringstream ss(s);
        string token;
        while(getline(ss, token, delit))
            res.push_back(token);
        return res;
    }

    int compareVersion(string version1, string version2) {
        auto V1=split(version1, '.'), V2=split(version2, '.');
        int n=V1.size(), m=V2.size();
        for(int i=0; i<n||i<m; i++){
            int ver1=i<n?stoi(V1[i]):0;
            int ver2=i<m?stoi(V2[i]):0;
            if(ver1!=ver2) return ver1<ver2?-1:1;
        }
        return 0;
    }
};